package com.gdziarmaga.webshop.delivery.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.gdziarmaga.webshop.delivery.model.Delivery;
import com.gdziarmaga.webshop.delivery.model.DeliveryDAO;

@Service("deliveryManager")
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public class DeliveryManagerImpl implements DeliveryManager {

	@Autowired
	private DeliveryDAO deliveryDAO;

	@Override
	public Delivery getDeliveryById(Long deliveryId) {
		return deliveryDAO.getById(deliveryId);
	}

	@Override
	public Delivery getDeliveryByInvoice_number(String invoice_number) {
		return deliveryDAO.findProductByInvoice_number(invoice_number);
	}

	@Override
	public Delivery getDeliveryBySupplier_name(String supplier_name) {
		return deliveryDAO.findProductBySupplier_name(supplier_name);
	}

	@Override
	public void saveDelivery(Delivery Delivery) {
		deliveryDAO.save(Delivery);
	}

}
